Skip to content

feat: add formFiller to declaratively fill forms in page objects - #49

Merged
foxable merged 1 commit into
mainfrom
feat/fill-form
Oct 6, 2026
Merged

foxable merged 1 commit into
mainfrom
feat/fill-form

Conversation

@foxable

@foxable foxable commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Adds formFiller, a helper to fill forms in page objects from a data object.

  • Each key maps to a form input: anything with a fill method (e.g. a Locator or a nested page object) or a filler function such as (checked) => checkbox("Accept").setChecked(checked)
  • undefined values are skipped
  • fields are filled in the order of the fields object
  • formFiller can be nested because it returns a filler function
import { formFiller, roleLocators } from "@cronn/playwright-utils";
import type { Page } from "@playwright/test";

function createRegistrationForm(page: Page) {
  const { button, textbox } = roleLocators(page);

  return {    
    fill: formFiller({
      name: textbox("Name"),
      email: textbox("Email"),
    }),
    submitButton: button("Register"),
  };
}

@foxable foxable self-assigned this Sep 29, 2026
@changeset-bot

changeset-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: de8fdb9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cronn/playwright-utils Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@foxable
foxable force-pushed the feat/fill-form branch 3 times, most recently from 1ff991b to 3315509 Compare September 29, 2026 15:47
@foxable foxable changed the title feat: add fillForm to declaratively fill forms in page objects feat: add formFiller to declaratively fill forms in page objects Sep 29, 2026
@PMudra
PMudra self-requested a review October 5, 2026 06:44
Comment thread docs/src/page-object-model/forms.md
Comment thread src/page-object-model/form-filler.ts Outdated
@foxable
foxable force-pushed the feat/fill-form branch 2 times, most recently from 0026d39 to 89d2b82 Compare October 6, 2026 12:10
@foxable
foxable merged commit 0f25119 into main Oct 6, 2026
2 checks passed
@foxable
foxable deleted the feat/fill-form branch October 6, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants